﻿using System.ComponentModel;

namespace TianlalaHSB.Models;

// 1.实现IDataErrorInfo
// 2.xaml Binding 第二个属性增加 ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged
// 3.cs Validation.GetHasError 验证值
public class BaseQuery : IDataErrorInfo
{
    public string? headReqSerialNo { get; set; }

    /// <summary>
    ///     资金账户
    /// </summary>
    public string? subAcctNo { get; set; }

    // 返回特定属性的错误信息
    public string this[string columnName]
    {
        get
        {
            var result = string.Empty;
            switch (columnName)
            {
                case nameof(subAcctNo):
                    if (string.IsNullOrEmpty(subAcctNo))
                    {
                        result = "资金账号不能为空.";
                    }
                    else
                    {
                        if (subAcctNo.Length != 28) result = "资金账号位数错误.";

                        if (!subAcctNo.StartsWith("223018152231000008")) result = "资金账号输入错误.";
                    }

                    break;
            }

            return result;
        }
    }

    // 返回对象级别的错误信息
    public string Error => throw new NotImplementedException();
}